
// const owelcome = document.querySelector(".welcome")
// const oun = document.querySelectorAll(".un");
// const oexit = document.querySelector(".exit");
// const ogoCart = document.querySelector(".goCart");
// 读取登录信息
// if(localStorage.getItem("isLogin") === "ok"){
//     owelcome.style.display = "block";
//     for(i=0;i<oun.length;i++){
//         oun[i].innerHTML = localStorage.getItem("username");
//     }
// }else{
//     owelcome.style.display = "none";
//     oun.innerHTML = "xxx";
// }

// oexit.onclick = function(){
//     localStorage.removeItem("username");
//     localStorage.setItem("isLogin", "");
//     owelcome.style.display = "none";
//     oun.innerHTML = "xxx";
//     location.href = "./login.html"
// }

// ogoCart.onclick = function(){
//     if(localStorage.getItem("isLogin") === "ok"){
//         location.href = "./cart.html"
//     }else{
//         alert("未登录状态，不允许打开购物车，请先登录")
//         location.href = "./login.html"
//     }
// }





/* =================================================================== */

function ajax(url, callback, data){
    let str = "";
    for(let i in data){
        str += `${i}=${data[i]}&`
    }
    url += "?" + str;
    const xhr = new XMLHttpRequest();
    xhr.open("get",url)
    xhr.onload = function(){
        if(xhr.status === 200){
            callback(xhr.responseText)
        }
    }
    xhr.send();
}

